import cv2
import imutils
import numpy as np
from fuzzy1 import Gdt
from fuzzy1 import Ai
from fuzzy1 import compare

def Fuzzyscan(binaryimage,grayimage) :
    binaryimage1=binaryimage[0:109,0:164]
    binaryimage2=binaryimage[0:109,164:300]
    area1=len(binaryimage1[binaryimage1==255])
    area2=len(binaryimage2[binaryimage2==255])
    gm0=cv2.mean(grayimage[35:77,68:160])[0]
    gm1=cv2.mean(grayimage[35:77,160:250])[0]
    x=[]
    #gdt先是填涂再是未填涂
    if compare(Ai(Gdt(gm0,96.86471557,215.9680034),Gdt(area1,3324.083333,333715.9792)),Ai(Gdt(gm0,173.2690293,78.53247543),Gdt(area1,1319.925926,249032.0686)))==1 :
            x.append("Y")

    if compare(Ai(Gdt(gm1,96.86471557,215.9680034),Gdt(area2,3324.083333,333715.9792)),Ai(Gdt(gm1,173.2690293,78.53247543),Gdt(area2,1319.925926,249032.0686)))==1 :
            x.append("N")
    
    if len(x)!=0:
        return (' '.join(x))
 
   
    
        
    